const oldNum=12313123123123123.22
function toThousand(num){
    const [interger,decimal]=String.prototype.split.call(num,'.')
    const arr=[]
    let j=0
    for(let i=interger.length-1;i>=0;i--){
        arr.unshift(interger[i])
        j++
        if(j%3===0 && i!==0){
            arr.unshift(',')
        }
    }
    if(decimal){
        return `${arr.join('')}.${decimal}`
    }

}
console.log(toThousand(oldNum));
